package com.yeyaomai.dksns.flowis.service.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.data.domain.Page;
import org.springframework.stereotype.Service;
import com.yeyaomai.dksns.flowis.dao.ModuleDao;
import com.yeyaomai.dksns.flowis.domain.Module;
import com.yeyaomai.dksns.flowis.page.PageImplResult;
import com.yeyaomai.dksns.flowis.page.PageRequestOrder;
import com.yeyaomai.dksns.flowis.page.SplitConstant;
import com.yeyaomai.dksns.flowis.service.ModuleService;

@Service
public class ModuleServiceImpl implements ModuleService {

	
	@Resource
	private ModuleDao moduleDao;
	
	@Override
	public Module getModuleById(long id) {
		
		return moduleDao.getModuleById(id);
	}

	@Override
	public List<Module> getModuleByDay(Map<String, Object> map) {
		
		return moduleDao.getModuleByDay(map);
	}

	@Override
	public Page<Module> getDataPage(Map<String, Object> map, Integer currentpage) {
		
		long moduleCount = moduleDao.getModuleCount();
		PageRequestOrder request = new PageRequestOrder(currentpage,
				SplitConstant.PAGE_SIZE);
		List<Module> moduleList = new ArrayList<Module>();
		map.put("startNumber", request.start());
		map.put("endNumber", request.end());
		moduleList = moduleDao.getModuleByDay(map);
		Page<Module> result = new PageImplResult<Module>(moduleList,
				request, moduleCount);
		return result;
	}

	@Override
	public List<Module> getModuleByModuleName(Map<String, Object> map) {
		
		return moduleDao.getModuleByModuleName(map);
	}

}
